/*
 * @Author: Aster lipian1004@163.com
 * @Date: 2023-10-30 17:50:58
 * @FilePath: \aster-flowable-uniapp\src\api\sys\user.ts
 * @Description: 用户API
 * Copyright (c) 2024 by Aster, All Rights Reserved.
 */
import { request } from '@/utils/http';
import { PORT1 } from '../config';

/**
 * @description: 列表
 * @param {User.UserParams} params
 * @return {*}
 */
export const userPageApi = (params: User.UserParams) => {
  return request.get<Page.ResPage<User.UserInfo>>(PORT1 + `/user/page`, { params: params });
};

/**
 * @description: 通过角色id获取用户列表
 * @param {User.UserParams} params
 * @return {*}
 */
export const userPageByRoleIdApi = (roleId: string) => {
  return request.get<Page.ResPage<User.UserInfo>>(PORT1 + `/user/pageByRoleId?roleId = ` + roleId);
};

/**
 * @description: 单条信息
 * @param {string} id
 * @return {*}
 */
export const userInfoApi = (id: string) => {
  return request.get<User.UserInfo>(PORT1 + `/user/info/` + id);
};

/**
 * @description: 保存
 * @param {User.UserInfo} user
 * @return {*}
 */
export const userSaveApi = (user: User.UserInfo) => {
  return request.post<string>(PORT1 + `/user/save`, user);
};

/**
 * @description: 批量保存
 * @param {User.UserInfo} user
 * @return {*}
 */
export const userBatchSaveApi = (users: User.UserInfo[]) => {
  return request.post<string>(PORT1 + `/user/save`, users);
};

/**
 * @description: 修改
 * @param {User.UserInfo} user
 * @return {*}
 */
export const userEditApi = (user: User.UserInfo) => {
  return request.post<string>(PORT1 + `/user/edit`, user);
};

/**
 * @description: 删除
 * @param {string[]} ids
 * @return {*}
 */
export const userDeleteApi = (ids: string[]) => {
  return request.post<string>(PORT1 + `/user/delete`, ids);
};

// 修改密码
export const editPasswordApi = (params: Login.ResetPassword) => {
  return request.post<string>(PORT1 + `/user/password`, params);
};

/**
 * @description: 导出用户数据
 * @param {*} params
 * @return {*}
 */
export const userExportApi = (params: User.UserInfo) => {
  return request.download(PORT1 + `/user/export`, { params: params });
};

/**
 * @description: 批量获取用户信息
 * @param ids
 * @return {*}
 */
export const selectUsersByIdsApi = (ids: string[]) => {
  return request.post<User.UserInfo[]>(PORT1 + `/user/selectBatchIds`, ids);
};

/**
 * @description: 通过部门ids批量获取用户信息
 * @param ids
 * @return {*}
 */
export const selectUsersByDeptIdsApi = (ids: string[]) => {
  return request.post<User.UserInfo[]>(PORT1 + `/user/selectBatchDeptIds`, ids);
};

/**
 * @description: 通过系统角色ids批量获取用户信息
 * @param ids
 * @return {*} 返回用户id集合
 */
export const selectUsersByRoleIdsApi = (ids: string[]) => {
  return request.post<Role.RoleUserInfo[]>(PORT1 + `/user/selectBatchRoleIds`, ids);
};

/**
 * @description: 通过部门ID查询部门人员信息
 * @param {string} deptId 部门ID
 * @return {*}
 */
export const userDeptInfoApi = (deptId: string) => {
  return request.get<User.UserDeptModel[]>(PORT1 + `/user/userDeptInfo` + '?deptId=' + deptId);
};

/**
 * @description: 获取所有用户信息
 * @return {*}
 */
export const userAllApi = () => {
  return request.get<User.UserInfo[]>(PORT1 + `/user/all`);
};
